﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class DeleteDatabase : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Request.QueryString != null && Request.QueryString.Count > 0)
            {
                ProxyWrapper.UserProxy.UserDetails _objUser = ((ProxyWrapper.UserProxy.UserDetails)Session["UserObject"]);
                int dbId = 0;
                Int32.TryParse(Request.QueryString[0].ToString(), out dbId);
                ProxyWrapper.DatabaseServiceWrapper _dbService = new ProxyWrapper.DatabaseServiceWrapper();
                string msg = _dbService.DeleteDatabase(dbId, _objUser.ClientId);
                if (msg == "0")
                    Response.Redirect("Databases.aspx?msg=Database deleted.", false);
                else
                    Response.Redirect("Databases.aspx?msg=" + msg, false);
            }
        }
        catch (Exception ex)
        {
            Response.Redirect("Databases.aspx?msg=Error while deleting user  . " + ex.Message, false);
        }
    }
}